import redis

# 配置Redis连接信息
redis_host = '124.221.66.3'  # Redis服务器地址
redis_port = 6379  # Redis服务器端口
redis_db = 0  # Redis数据库索引
password = ''
decode_responses = False

# 创建Redis无密码连接
client = redis.StrictRedis(host=redis_host, port=redis_port, db=redis_db,password=password, decode_responses=decode_responses)

# 测试Redis连接
try:
    # 尝试ping Redis服务器
    response = client.ping()
    if response:
        print("Redis connection successful.")
    else:
        print("Failed to connect to Redis.")
except redis.exceptions.ConnectionError:
    print("Failed to connect to Redis.")